package org.test.demo.pattern.proxy;

import org.test.demo.pattern.proxy.impl.ToBPaymentImpl;
import org.test.demo.pattern.proxy.impl.ToCPaymentImpl;
import org.test.demo.pattern.proxy.jdk.AliPayInvocationHandler;
import org.test.demo.pattern.proxy.jdk.JdkDynamicProxyUtil;

public class ProxyDemo {
    public static void main(String[] args) {
        //ToCPayment toCPayment =new AlipayToC(new ToCPaymentImpl());
        //toCProxy.pay();
        ToCPayment toCPayment =new ToCPaymentImpl();
        AliPayInvocationHandler handler = new AliPayInvocationHandler(toCPayment);
        ToCPayment toCProxy = JdkDynamicProxyUtil.newProxyInstance(toCPayment, handler);
        toCProxy.pay();
        //ToBPayment toBPayment = new AliPayToB(new ToBPaymentImpl());
        ToBPayment toBPayment = new ToBPaymentImpl();
        //toBProxy.pay();
        AliPayInvocationHandler handler1 = new AliPayInvocationHandler(toBPayment);
        ToBPayment toBProxy = JdkDynamicProxyUtil.newProxyInstance(toBPayment, handler1);
        toBProxy.pay();
    }
}
